package com.ruicar.afs.cloud.image.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.image.entity.ComAttachmentManagement;
import com.ruicar.afs.cloud.image.mapper.ComAttachmentManagementMapper;
import com.ruicar.afs.cloud.image.service.ComAttachmentManagementService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ComAttachmentManagementServiceImpl extends ServiceImpl<ComAttachmentManagementMapper, ComAttachmentManagement> implements ComAttachmentManagementService {

    /**
     * 获取附件管理信息
     * @param busiNo
     * @param uniqueCode
     * @return
     */
    public ComAttachmentManagement getAttachmentManagement(String busiNode,String uniqueCode){

        List<ComAttachmentManagement> list = this.baseMapper.selectList(Wrappers.<ComAttachmentManagement>query().lambda()
                .eq(ComAttachmentManagement::getBusiNode,busiNode).eq(ComAttachmentManagement::getUniqueCode,uniqueCode)
                .orderByDesc(ComAttachmentManagement::getCreateTime));
        if(CollectionUtil.isNotEmpty(list)){
            return list.get(0);
        }
        return null;
    }
}
